home *** CD-ROM | disk | FTP | other *** search
/ Whiteline: delta / whiteline CD Series - delta.iso / tex / style / misc / draft.sty < prev    next >
Internet Message Format  |  1995-11-25  |  10KB

  1. From root Wed Oct  6 12:04:53 1993
  2. Received: from niord.shsu.edu by numerik.FernUni-Hagen.de (AIX 3.2/UCB 5.64/4.04.CS)
  3.           id AA22414; Wed, 6 Oct 1993 11:58:46 +0100
  4. Message-Id: <9310061058.AA22414@numerik.FernUni-Hagen.de>
  5. Received: by SHSU.edu (MX V3.3 VAX) id 23265; Mon, 04 Oct 1993 04:09:28 CST
  6. Date: Mon, 04 Oct 1993 04:09:28 CST
  7. Sender: FILESERV-Mgr@SHSU.edu
  8. Errors-To: FILESERV-Mgr@SHSU.edu
  9. Warnings-To: <>
  10. From: FILESERV-Mgr@SHSU.edu
  11. Reply-To: FILESERV@SHSU.edu
  12. Subject: LTX3PUB.DRAFT_STY
  13. To: schrell@numerik.FernUni-Hagen.de
  14. Status: O
  15.  
  16. % NAME THIS FILE: draft.sty (or name it draft.doc and run it through
  17. % doc2sty) AND PUT IT IN YOUR MACROS OR TEXFORMATS DIRECTORY
  18. %
  19. % This is a first attempt at a draft option for the standard LaTeX styles.
  20. % It still has several problems, which are detailed below.
  21. % The draft option attempts to accomplish the following:
  22. %  Without requiring any changes to a LaTeX file (other than specifying
  23. %  the draft option :-) and without changing the formatting of the 
  24. %  ``real'' text , mark the spots where \label, \cite, \ref, \index,
  25. %  or \glossary commands occur in text, and print the command arguments
  26. %  in the margin.
  27. %
  28. % USAGE:
  29. % Specify draft as an optional argument to the documentstyle command
  30. % e.g., \documentstyle[11pt,draft]{book}
  31. %
  32. % JUSTIFICATION:
  33. % Why am I submitting this, even though it still has some problems?
  34. %
  35. %     1) Even in its present shape, I think it is fairly useful.
  36. %        I was going crazy before, trying to remember labels, keys,
  37. %        and so forth.  I am still going crazy, but now for different
  38. %        reasons.
  39. %     2) I'm just learning TeX, and don't expect to know enough to do this
  40. %        correctly for a while.  Hopefully, someone who knows TeX will
  41. %        agree this is a useful option, and will point out my mistakes.
  42. %        Since the changes to the standard LateX routines are fairly minor,
  43. %        and my mistakes are probably silly and quite obvious, this
  44. %        may be easy to do.
  45. %     3) I am interested in hearing ideas for other features for this
  46. %        option.  This option includes some of the ideas of Dr. Rouben 
  47. %        Rostamian (rostamia@umbc3.UMD.EDU) and I am interested in 
  48. %        hearing from others.
  49. %     4) Because of 2) and 3), I think we will end up with a better
  50. %        draft option if I post this in its present form and ask for
  51. %        help.
  52. %
  53. %     Please send bugs, fixes, and suggestions to:
  54. %      Joe Baker 
  55. %      6731 Boelter Hall   UCLA   L.A., CA 90024   (213) 825-7079, 825-2327
  56. %      INTERNET: jbaker@ee.ucla.edu 
  57. %      UUCP: {ucbvax, or other backbone}!ucla-cs!uclaee!jbaker
  58. %
  59. % FINALLY, THE DETAILS
  60. %
  61. % The option marks \label,\cite,\ref,\index, and \glossary commands in the
  62. % text with a scriptsize calligraphic letter in the interline space 
  63. % (L for label,
  64. % C for cite, R for ref, I for index and G for glossary.
  65. % The label, citation, is printed in the margin in scriptsize bold letters.  
  66. %   
  67. % For items which are input in horizontal mode, a \marginpar box holding 
  68. % the text is put in the right margin (if there are no free boxes left, 
  69. % the next option is used.) 
  70. % Items which are input in display math mode are shoved into the left
  71. % margin (parboxes are not used, so it is possible for one label to 
  72. % overwrite another, or for a label to run off the left edge of the page.)
  73. % Items which are input in non-display math mode and equation arrays
  74. % are giving me problems.  The left margin code works fine for equations
  75. % in the middle of text, but doesn't produce anything for equation arrays.
  76. % Unfortunately, I haven't found a way to distinguish between the two
  77. % cases.  For now, I simply raise the item and print it in small letters,
  78. % and hope to avoid hitting any superscripts.
  79. % Right now, a space or extra bit of glue is getting inserted where the 
  80. % item is, and thus the ``real'' text is not formatted quite the same in
  81. % draft mode.  On the tests I've run so far, there hasn't been enough
  82. % added space to actually change any of the linebreaks, so it doesn't
  83. % seem to be a serious problem.
  84. %
  85. %%%%%%%%%%%%%%%%%%%%%%%%%%%%% Okay, here it is %%%%%%%%%%%%%%%%%%%%%%%%%%
  86. % NOTE THIS:
  87. % force all marginpar items into the right margin, to leave the left 
  88. % margin for calls to marginalnote.
  89. \@mparswitchfalse
  90. %                     
  91. %
  92. % MARGINALNOTE
  93. %
  94. % The following is a slightly rewritten version of Knuth's marginalstar stuff
  95. % from the TeXBook, pg. 316.  It is used to put a marginalnote in the left
  96. % margin.  The note is just shoved out and made right justified w.r.t. the
  97. % left margin.  Two calls to marginalnote for the same line of text will
  98. % be written one over the other.  Long marginal notes will extend off the
  99. % page to the left.
  100. %
  101. \def\strutdepth{\dp\strutbox}%
  102. \def\marginalnote#1{\strut\vadjust{\kern-\strutdepth\specialnote{#1}}}%
  103. \def\specialnote#1{\vtop to \strutdepth{\baselineskip%
  104. \strutdepth\vss\llap{\hbox{\scriptsize \bf #1}}\null}}%
  105. %
  106. % NOTEMARK
  107. % This is used to put a little calligraphic letter in the text to mark
  108. % the spot where the item occurred.
  109. %
  110. \def\notemark#1{\rlap{%
  111. \specialnote{\raise8pt\hbox{$\scriptscriptstyle\cal#1$}}}}
  112. %
  113. % Since I haven't found one approach that works in all modes, I
  114. % have set up the makenote routine to use the following options
  115. % (draftimm, draftdmm, draftinm, drafthm) in inner math mode,
  116. % display math mode, inner non-math mode, and horizontal mode.
  117. % If you don't like one, redefine it before the begin{document}
  118. % line.
  119. \def\draftimm#1{\hbox{\bf \scriptsize #1}}
  120. \def\draftdmm#1{\marginalnote{#1}}
  121. \def\draftinm#1{\notemark{\bf \scriptsize #1}}
  122. \def\drafthm#1{\ifx\@freelist\@empty % if there are no boxes for a marginpar,
  123.                    \marginalnote{#1}  % use a marginalnote
  124.                  \else                  
  125.                    {\marginpar{\scriptsize \bf #1}}
  126.                  \fi}
  127.  
  128. %
  129. % MAKENOTE
  130. % this routine prints the command argument.  It tries to do the best it
  131. % can for the given mode.
  132. %
  133. %\def\makenote#1{            
  134. %                            
  135. %                            
  136. %    \ifmmode                % In math mode, we can't use 
  137. %                            % \marginpar, so we use marginalnote
  138. %                            % in display mode, and for now,
  139. %                            % just use bold print in inner mode
  140. %                            % marginalnote works okay in regular
  141. %                            % non-display math, but not in
  142. %                            % eqnarrays. By redefining draft...
  143. %                            % you can change this behavior.
  144. %        \ifinner
  145. %           \draftimm{#1} 
  146. %        \else
  147. %           \draftdmm{#1} 
  148. %        \fi
  149. %    \else
  150. %        \ifinner
  151. %           \draftinm{#1} 
  152. %         \else
  153. %           \drafthm{#1} 
  154. %         \fi
  155. %    \fi}
  156. \def\makenote#1{\ifmmode\ifinner\draftimm{#1}%
  157. \else\draftdmm{#1}\fi%
  158. \else\ifinner\draftinm{#1}%
  159. \else%
  160. \drafthm{#1}%
  161. \fi\fi}
  162. %
  163. % MODIFIED LATEX ROUTINES
  164. % We add the \notemark and \makenote routines to the \ref, \pageref,
  165. % \label, \index, \glossary, and \cite commands.
  166. %
  167. % REF
  168. %
  169. %  \ref{FOO} ==
  170. %    BEGIN
  171. %         make a reference mark in the text (calligraphic R)
  172. %      if \r@foo undefined  
  173. %        then  ?? 
  174. %              Warning: 'reference foo on page ... undefined'
  175. %        else  \@car \eval(\r@FOO)\@nil
  176. %      fi
  177. %        make a reference note (hopefully in the margin) listing the
  178. %        reference key
  179. %    END
  180. %
  181. \def\ref#1{\notemark{R}%
  182. \@ifundefined{r@#1}{{\bf ??}\@warning%
  183. {Reference `#1' on page \thepage \space %
  184. undefined}}{\edef\@tempa{\@nameuse{r@#1}}\expandafter%
  185. \@car\@tempa \@nil\null}\makenote{R:#1}}
  186. %
  187. % PAGEREF
  188. %
  189. %  \pageref{foo} = 
  190. %    BEGIN
  191. %      make a page reference mark in the text (calligraphic PR)
  192. %      if \r@foo undefined  
  193. %        then  ?? 
  194. %              Warning: 'reference foo on page ... undefined'
  195. %        else  \@cdr \eval(\r@FOO)\@nil
  196. %      fi
  197. %      make a reference note (hopefully in the margin) listing the
  198. %      page reference key
  199. %    END
  200. %
  201. \def\pageref#1{\notemark{PR}%
  202. \@ifundefined{r@#1}{{\bf ??}\@warning%
  203. {Reference `#1' on page \thepage \space %
  204. undefined}}{\edef\@tempa{\@nameuse{r@#1}}\expandafter%
  205. \@cdr\@tempa\@nil\null}\makenote{PR:#1}}%
  206. %
  207. % LABEL
  208. %
  209. % same story for the label routine
  210. \def\label#1%
  211. {\notemark{L}\makenote{L:#1}\@bsphack%
  212. \if@filesw{\let\thepage\relax%
  213. \xdef\@gtempa{\write\@auxout{\string%
  214. \newlabel{#1}{{\@currentlabel}{\thepage}}}}}\@gtempa%
  215. \if@nobreak\ifvmode\nobreak\fi\fi\fi\@esphack}
  216. %
  217. % INDEX 
  218. %  note that \@wrindex is normally used by both the index and the 
  219. %  glossary commands.  We will make a new version for the glossary
  220. %  command that differs only in putting out a G instead of an I.
  221. %
  222. %  \@wrindex{ITEM} ==
  223. %    BEGIN
  224. %     make an I mark in the text, and put the index item in the margin
  225. %        write of {\indexentry{ITEM}{page number}}
  226. %      \endgroup
  227. %      \@esphack
  228. %    END
  229. %
  230. \def\@wrindex#1#2{\notemark{I}\makenote{I:#2}%
  231. \let\thepage\relax%
  232. \xdef\@gtempa{\write#1{\string \indexentry{#2}{\thepage}}}\endgroup\@gtempa%
  233. \if@nobreak \ifvmode\nobreak\fi\fi\@esphack}%
  234. %
  235. % GLOSSARY
  236. % version for use by glossary commands
  237. %
  238. \def\@wrindexg#1#2{\notemark{G}\makenote{G:#2}%
  239. \let\thepage\relax%
  240. \xdef\@gtempa{\write#1{\string \indexentry{#2}{\thepage}}}\endgroup\@gtempa%
  241. \if@nobreak \ifvmode\nobreak\fi\fi\@esphack}%
  242. %
  243. % new version of the glossary stuff: just changed @wrindex to @wrindexg
  244. %
  245. \def\makeglossary{\if@filesw \newwrite\@glossaryfile
  246.   \immediate\openout\@glossaryfile=\jobname.glo
  247.   \def\glossary{\@bsphack\begingroup\@sanitize\@wrindexg\@glossaryfile}\typeout
  248.   {Writing glossary file \jobname.glo }\fi}
  249. %
  250. % CITE
  251. %
  252. % citex is used by the bibliography citation routines
  253. % the second argument is the citation key
  254. %
  255. \def\@citex[#1]#2{\notemark{C}\makenote{C:#2}%
  256. \if@filesw\immediate\write\@auxout{\string\citation{#2}}\fi%
  257. \def\@citea{}\@cite{\@for\@citeb:=#2\do%
  258. {\@citea\def\@citea{,}\@ifundefined%
  259. {b@\@citeb}{{\bf ?}\@warning%
  260. {Citation `\@citeb' on page \thepage \space undefined}}%
  261. \hbox{\csname b@\@citeb\endcsname}}}{#1}}
  262.  
  263.  
  264. ə